home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / ste / autoexec.lzh / SOURCE / COOKIE.C < prev    next >
C/C++ Source or Header  |  1991-08-05  |  745b  |  37 lines

  1. #include <tos.h>
  2.  
  3.  
  4. int get_cookie(long cookie, long *p_value)
  5. /* Returns zero if the 'cookie' is not found in the jar. 
  6.  * if the cookie is found it returns non zero and places the
  7.  * value in the longword pointed to by 'p_value'. If 'p_value'
  8.  * is '0l' it does not put the value anywhere...
  9.  */
  10. {void *oldssp;
  11.  long *cookiejar;
  12.  int ret;
  13.  
  14.      ret = 0;
  15.  
  16.     if (Super((void *)1L) == 0l)
  17.         oldssp = (void *)Super((void *)0l);
  18.     else
  19.         oldssp = 0;
  20.  
  21.     if ((cookiejar = *(long **)0x5A0) != 0l)
  22.     {
  23.         do
  24.         {    if (*cookiejar == cookie)
  25.             {    if (p_value != 0l)
  26.                     *p_value = *(cookiejar + 1);
  27.                 ret = 1;
  28.                 break;
  29.             }
  30.             cookiejar += 2;
  31.         } while (*cookiejar != 0);
  32.     }
  33.  
  34.     if (oldssp != 0) Super(oldssp);
  35.     return ret;
  36. }
  37.